import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

let time = `${new Date().getFullYear()}${new Date().getMonth() + 1 < 10 ? '0' + (new Date().getMonth() + 1)  : new Date().getMonth() + 1 }${new Date().getDate() < 10 ? '0' + new Date().getDate() : new Date().getDate()}`

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueJsx(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server : {
    port : 8054
  },
  build : {
    rollupOptions: {
      input: {
        main: './index.html',
        login: './login.html',
      },
    },
    outDir : `./dist/${time}`,
  }
})
